package com.tbit.main.controller;

import com.tbit.main.pojo.Result;
import com.tbit.manager.api.MemberFeeApi;
import com.tbit.manager.api.dto.UserMemberDTO;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import javax.validation.constraints.NotNull;
import java.util.List;


/**
 * 免押会员费
 */
@Validated
@RestController
@RequestMapping(value = "/memberFee")
public class MemberFeeController {

    @Autowired
    private MemberFeeApi memberFeeApi;

    /**
     * 用户购买的免押套餐记录分页
     *
     * @param userId     用户id
     * @param pageSize   条数
     * @param pageNum 页码
     * @return Result<List<UserMemberDTO>>
     */
    @GetMapping("/userMemPage")
    public Result<List<UserMemberDTO>> userMemPage(@RequestParam("userId") @NotNull Integer userId,
                                                   @RequestParam(value = "pageSize", defaultValue = "10") Integer pageSize,
                                                   @RequestParam(value = "pageNum", defaultValue = "1") Integer pageNum) {

        List<UserMemberDTO> userMemberDTOList = memberFeeApi.userMemPage(userId, pageSize, pageNum);
        return Result.success(userMemberDTOList);
    }

}
